<template>
	<view class="index p10">
		<view class="p10 dfbc bs6 bf mb10">
			<text>全额退款</text>
			<view class="" style="width: 30px;">
				<u-checkbox-group v-model="check" shape="circle" :activeColor="subColor" placement="column"
					@change="checkboxChange">
					<u-checkbox label=" " :name="0"></u-checkbox>
				</u-checkbox-group>
			</view>
		</view>
		<view class="p10 dfbc bs6 bf mb10">
			<text>支付金额</text>
			<view class="">￥ <text>{{money}}</text> </view>
		</view>
		<view class="p10 bs6 bf mb10">
			<view class="mb10 c0">退款原因</view>
			<u--textarea v-model="reason" placeholder="选填"></u--textarea>
		</view>
		<view class="but p10">
			<u-button text="确认退款" :color="subColor" shape="circle" size="large" @click="save">
			</u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				subColor: uni.getStorageSync('subject_color'),
				check: [0],
				reason: '',
				id: '',
				money: '',
				storeId: '',
				type: '',
			}
		},
		onLoad(options) {
			if (options && options.id) {
				this.id = options.id
				this.money = options.money
				this.storeId = options.storeId
				this.type = options.type
			}
		},
		methods: {
			async save() {
				uni.showModal({
					title: '温馨提示',
					content: '您确认退款吗',
					success: async (res) => {
						if (res.confirm) {
							let {
								msg
							} = await this.beg.request({
								url: `${this.type=='inStore' ? this.api.inRefund : this.api.refund}/${this.id}`,
								method: "POST",
								data: {
									storeId: this.storeId,
									reason: this.reason,
								},
							})
							uni.$u.toast(msg)
							uni.reLaunch({
								url: `/pages/order/detail?id=${this.id}`
							})
						}
					}
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.but {
		width: 100%;
		position: fixed;
		left: 0;
		bottom: 100rpx;

		/deep/.u-button__text {
			font-size: 33rpx !important;
		}
	}
</style>